import java.util.Scanner;

public class 游游的数字圈 {
    //https://www.nowcoder.com/practice/16eafa41a4a242b8870cb2c5420ae089?tpId=376&tqId=10476730&ru=/exam/oj&qru=/ta/15-days-help/question-ranking&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E7%25AE%2597%25E6%25B3%2595%25E9%259D%25A2%25E8%25AF%2595%26topicId%3D376
    //很简单的模拟题
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int sum = 0;
        for(int i = 0;i < s.length();i++){
            char ch = s.charAt(i);
            if(ch == '0' || ch == '6' || ch == '9'){
                sum++;
            }else if(ch == '8'){
                sum += 2;
            }
        }
        System.out.println(sum);
    }

}
